package com.weiai.wedding.dao.user;
import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.weiai.wedding.entity.user.User;
import com.weiai.wedding.util.StatusConstants;
public interface UserDao extends JpaRepository<User, String> {
	/**
	 * 根据用户name查询 对应用户上传的所有文件信息
	 * @param loginName
	 * @return
	 */
	@Query("select u from User u where u.loginName=:loginName and u.status!='"+StatusConstants.DELETE_STATUS+"'")
	User findByLoginName(@Param("loginName")String loginName);
	
	@Query("select u from User u left join u.authList a where a = :authCode  and u.status!='"+StatusConstants.DELETE_STATUS+"'")
	List<User> findUserByAuthCode(@Param("authCode")String authCode);
	
	@Query("select u from User u where u.status!='"+StatusConstants.DELETE_STATUS+"'")
	Page<User> findAllUser(Pageable pager);
	
	@Query("select u from User u where u.status!='"+StatusConstants.DELETE_STATUS+"' and u.loginName like :loginName")
	Page<User> findUserAllByLoginName(@Param("loginName")String loginName, Pageable pageable);
}
